Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined symbol: json_object_from_file #2

Closed
vbouchaud opened this issue May 24, 2011 · 4 comments
Closed

Undefined symbol: json_object_from_file #2

vbouchaud opened this issue May 24, 2011 · 4 comments

Comments

@vbouchaud
Copy link

All is already in the title, I just can put an example below:

➜ cfuu git:(master) make
gcc -W -Wall -pedantic -ansi -Wshadow -Werror -g -I/usr/local/include -c -o fuu.o fuu.c
gcc fuu.o -o fuu -L/usr/local/lib -ljson
➜ cfuu git:(master) ✗ ./fuu
./fuu: symbol lookup error: ./fuu: undefined symbol: json_object_from_file

I can assure that libraries are in /usr/local/lib and include <json/json.h> in /usr/local/include

@hawicz
Copy link
Member

hawicz commented Oct 7, 2011

Well, it's there in the current code so if you're using a recent build that should work.
Can you provide some more information: what OS+version are you using? What version of json-c? If you run nm on the library, do you see the json_object_from_file symbol?

If you run ldd on the fuu binary, does it find the right json library?

@vbouchaud
Copy link
Author

I don't remember exactly what append and I lost the binary but:

#define JSON_MAJOR 0
#define JSON_MINOR 7

I'm on archlinux x86_64 with kernel 3.0

When I nm the lib, I have :
[...]
json_util.o:
U __stack_chk_fail
U close
0000000000000000 T json_object_from_file
00000000000000d0 T json_object_to_file
U json_object_to_json_string
U json_tokener_parse
U open
U printbuf_free
U printbuf_memappend
U printbuf_new
U read
U strlen
U write
[...]

edit: I can't do another test with fuu right now but if you want, I'll can try to find this old project.

@vbouchaud vbouchaud reopened this Oct 13, 2011
@hawicz
Copy link
Member

hawicz commented Oct 13, 2011

That looks like you're running nm on a static library, but the commands from your original message imply that you were using a shared library. (if you were using a static library there, the gcc command to link the fuu binary would have failed).

Also, json-c does not have JSON_MAJOR or JSON_MINOR defines. Are you sure you're using the right json library? For instance, there's a completely different (and somewhat simpler) project called "libjson" that has the same name for the library as json-c, so perhaps you're getting the wrong one linked in.

If you run ldd on your fuu binary it should tell you the full path to the libjson.so it uses. Then you can use rpm or whatever package manager is present on your system to check what package that library is from.

@hawicz
Copy link
Member

hawicz commented Dec 9, 2011

Well, I'm assuming this was just an issue of linking against the wrong library, so I'm going to close this. However, refer over to Issue #5 for possible improvements to avoid problems like this in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants